#include "OGLError.h"

#include <Windows.h>
#include <gl\GL.h>
#include <gl\glext.h>

OGLException::OGLException(const std::string & iMessage)
   :Exception(iMessage)
{

}


void OGLError::check_ogl_error()
{
   GLenum err = glGetError();
   if(err != GL_NO_ERROR)
   {
      std::string errMsg;
      switch(err)
      {
      case GL_INVALID_ENUM :
         errMsg = "GL_INVALID_ENUM";
         break;
      case GL_INVALID_OPERATION :
         errMsg = "GL_INVALID_OPERATION";
         break;

      case GL_STACK_OVERFLOW :
         errMsg = "GL_STACK_OVERFLOW";
         break;

      case GL_STACK_UNDERFLOW :
         errMsg = "GL_STACK_UNDERFLOW";
         break;

      case GL_OUT_OF_MEMORY :
         errMsg = "GL_OUT_OF_MEMORY";
         break;

      default :
         errMsg = ("Not in the List !");
         break;
      }

      throw new OGLException(errMsg);
   }
}

void OGLError::purge_ogl_error()
{
   glGetError();
}

